import throttle from 'lodash.throttle'
export default (callback) => {
  let startY = document.body.scrollTop || document.documentElement.scrollTop
  let dir = 'up'
  document.addEventListener('scroll', throttle(() => {
    const tmpY = document.body.scrollTop || document.documentElement.scrollTop
    if (tmpY > startY) {
      dir = 'up'
    } else {
      dir = 'down'
    }
    if (callback) {
      callback(dir, tmpY)
    }
    startY = tmpY
  }, 100), false)
}
